/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package launchPoints;

/**
 *
 * @author hubert
 */
public class consolidateVectorsIntoCSV {
    static java.io.File isCancerVectors = new java.io.File("/home/hubert/hadoopStuff/sampleCodeRun/wordVectors/isCancer");
    static java.io.File restVectors = new java.io.File("/home/hubert/hadoopStuff/sampleCodeRun/wordVectors/rest");
    
    public String getHeaders (decisionTree.top100List in){
        java.lang.StringBuilder serve = new java.lang.StringBuilder();
        serve.append("filenm,");
        
        for(decisionTree.stringWeightPair en : in.getWordWeightList()){
            serve.append(en.string + ",");
        }
        serve.append("isCancer");
        return serve.substring(0, serve.length());
    }
    
    public String getValues(String entryNm, boolean isCancer, decisionTree.top100List in){
        java.lang.StringBuilder serve = new java.lang.StringBuilder();
        serve.append(entryNm+",");
        
        for(decisionTree.stringWeightPair en : in.getWordWeightList()){
            serve.append(en.weight + ",");
        }
        serve.append(""+isCancer);
        return serve.substring(0, serve.length());
    }
    
    public void go() {
        if (this.isCancerVectors.exists() && this.restVectors.exists()) {
            try {
                decisionTree.top100List zScores = new decisionTree.top100ListZScore();
                System.out.println(this.getHeaders(zScores));
                //System.out.println(this.getValues("hi", zScores));
                for(java.io.File vect : this.isCancerVectors.listFiles()){
                    //System.out.println(vect.toString());
                    decisionTree.top100List wrdVector= new decisionTree.top100List(vect, "\t");
                    System.out.println(this.getValues(vect.getName().replace(",", ""), true, wrdVector));
                }
                for(java.io.File vect : this.restVectors.listFiles()){
                    //System.out.println(this.isCancerVectors.getAbsolutePath() + "/" + article.getName());
                    decisionTree.top100List wrdVector= new decisionTree.top100List(vect, "\t");
                    System.out.println(this.getValues(vect.getName().replace(",", ""), false, wrdVector));
                }
            } catch (java.lang.Exception e) {
                e.printStackTrace();
            }

        } else {
            System.out.println("unable to locate source files");
        }
    }
    
    public static void main(String[] args){
        consolidateVectorsIntoCSV a = new consolidateVectorsIntoCSV();
        a.go();
    }
}
